<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 流年 <liu21st@gmail.com>
// +----------------------------------------------------------------------

// 应用公共文件

/*************************************************************
	getRoot 获取网站跟目录
	@return  string 
*************************************************************/
function getRoot(){
	$rootUrl = request()->rootUrl();
	$rootUrl = preg_replace(['/\/public/i'],[''],$rootUrl);
	return trim($rootUrl) ? trim($rootUrl).'/': "/" ;
}

function returnJson($code=200,$data=[],$msg='请求成功'){
	$result['code'] = $code;
	$result['data'] = $data;
	$result['msg'] = $msg;
	$result = json_encode($result,JSON_UNESCAPED_UNICODE);
	return $result;
}

// 密码加密
function encrypt($str){
    return md5('brs'.$str);
}